package exam.web.action;

import exam.business.service.SubQuestionGetService;
import exam.common.key.KeySubQuestion;
import exam.common.util.NullCheckUtil;
import exam.model.entity.TSubQuestionEntity;
import exam.web.action.base.SubQuestionActionBase;

/**
 * <p>ViewSubQuestionAction</p>
 * <p>Action: Xem thông tin chủ đề câu hỏi</p>
 * 
 * @author Phong
 * @version 09/05/2012
 */
public class ViewSubQuestionAction extends SubQuestionActionBase {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String execute() throws Exception {
		String subQuestId = request.getParameter(KeySubQuestion.SUB_QUEST_ID);
		if (NullCheckUtil.isNull(subQuestId)) {
			addActionError("#id không hợp lệ");
			return ERROR;
		}
		serviceInfo.put(KeySubQuestion.SUB_QUEST_ID, subQuestId);
		SubQuestionGetService subQuestionGetService = new SubQuestionGetService();
		String port = subQuestionGetService.executeService(serviceInfo);
		if(NONE.equals(port)) {
			addActionError("Không tìm thấy danh mục câu hỏi có id: " + subQuestId);
		} else {
			addActionMessage("Danh mục câu hỏi: " + subQuestId);
			TSubQuestionEntity tSubQuestionEntity = serviceInfo.getObject(KeySubQuestion.T_SUB_QUESTION_ENTITY);
			copyFromTSubQuestionEntity(tSubQuestionEntity);
		}
		return SUCCESS;
	}
}
